﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Media3D;

namespace EQEmu.Display3D
{
    public interface IViewConstrainer
    {
        void UpdateView(ViewConstraints constraints);
    }

    public class ViewConstraints
    {
        public ViewConstraints()
        {
            MinZ = MaxZ = MinY = MaxY = MinX = MaxX = null;
        }

        public double? MaxX { get; set; }
        public double? MinX { get; set; }
        public double? MaxY { get; set; }
        public double? MinY { get; set; }
        public double? MaxZ { get; set; }
        public double? MinZ { get; set; }

        public bool IsPointWithinConstraints(Point3D point)
        {
            if (MaxX != null)
            {
                if (point.X > MaxX) return false;
            }

            if (MinX != null)
            {
                if (point.X < MinX) return false;
            }

            if (MaxY != null)
            {
                if (point.Y > MaxY) return false;
            }

            if (MinY != null)
            {
                if (point.Y < MinY) return false;
            }

            if (MaxZ != null)
            {
                if (point.Z > MaxZ) return false;
            }

            if (MinZ != null)
            {
                if (point.Z < MinZ) return false;
            }

            return true;
        }
    }
}
